<template>
    <div>
        <el-table :data="tableData.listdata.slice((currentPage-1)*pageSize,currentPage*pageSize)" style="width: 100%">
            <el-table-column prop="id" label="编号"  />
            <el-table-column prop="title" label="楼盘名称"  />
            <el-table-column prop="type" label="房源类型" />
            <el-table-column prop="num" label="门牌号" />
            <el-table-column prop="hometype" label="房源户型" />
            <el-table-column prop="name" label="户主" />
            <el-table-column>
                <template #header>
                    <el-input v-model="search" size="small" placeholder="请输入查询内容" @blur="searchLink"/>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
        v-model:currentPage="currentPage"
        v-model:page-size="pageSize"
          :current-page="currentPage"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.listdata.length"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />

    </div>
</template>

<script lang="ts" setup>
import { ref,onMounted,reactive } from 'vue'
import link from "../../../api/request"
import apiUrl from "../../../api/url"
const currentPage = ref(1)
const pageSize = ref(15)
let search=ref("")
let tableData = reactive({
    listdata:[]
})
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handleSizeChange = (val:any) => {
  pageSize.value = val
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const handleCurrentChange = (val:any) => {
    currentPage.value = val
}
let searchLink=()=>{
     link(apiUrl.userlist,"get",{},{name:search.value}).then((ok:any)=>{
        console.log(ok)
        tableData.listdata=ok.data
    })
}
onMounted(()=>{
    link(apiUrl.userlist).then((res:any)=>{
        console.log(res,222)
        tableData.listdata = res.data
    })
})
</script>

<style>

</style>